layui.use(["sdLocal", "sdHttp", "globalConfig"], function () {  
    let sdHttp = layui.sdHttp
    let sdLocal = layui.sdLocal;

    let application = {
        list: function () {
            let param = {
                url: '/v1/iam/user/application/toSelect',
                callback: function (d) {
                    let data = [];
                    if(d.length > 0){
                        let app = sdLocal.app.get();
                        $.each(d, function (i, item) {
                            if(item.id == app.id){
                                item.check = 1;
                            }else{
                                item.check = 0;
                            }
                            data.push(item);
                        })
                    }
					$('#application-view').vm({
						apps: data
					})
                }
            }
            sdHttp.get(param)
        }
    }
    application.list();
})